12. 解决方案:JOIN 问题(第一部分)

解决方案

  1. SELECT a.primary_poc, w.occurred_at, w.channel, a.name
    FROM web_events w
    JOIN accounts a
    ON w.account_id = a.id
    WHERE a.name = 'Walmart';
  2. 2.
SELECT r.name region, s.name rep, a.name account
FROM sales_reps s
JOIN region r
ON s.region_id = r.id
JOIN accounts a
ON a.sales_rep_id = s.id
ORDER BY a.name;
  1. SELECT r.name region, a.name account,
    o.total_amt_usd/(o.total + 0.01) unit_price
    FROM region r
    JOIN sales_reps s
    ON s.region_id = r.id
    JOIN accounts a
    ON a.sales_rep_id = s.id
    JOIN orders o
    ON o.account_id = a.id;